home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
wasm201.arc
/
MISC.MAC
< prev
next >
Wrap
Text File
|
1986-11-21
|
7KB
|
188 lines
List-
;============================================================================;
; Miscellaneous Macro Definitions ;
; ;
; The following macros provide various standard (non-i/o, non-operating ;
; system dependent) operations. For specific DOS functions, see the file ;
; DOS.MAC. For lower level i/o functions, see the file BIOS.MAC. ;
; ;
; The defined macros are: ;
; ;
; STRING_OFFSET return offset of a string, declare if necessary ;
; STRING_OFFSETZ return offset of a stringz, declare if necessary ;
; DECLARE_STRING declare a string ;
; DECLARE_STRINGZ declare a stringz ;
; INTERRUPT execute an interrupt ;
; IF_SAME conditional "if operands are same" ;
; IF_DIFFERENT conditional "if operands are different" ;
; IF_EXIST conditional "if operand exists" ;
; IF_NONE conditional "if operand doesn't exist" ;
; ;
; The two formats for strings are "string" and "stringz." The first format ;
; is used for standard string manipulations and consists of a string of any ;
; ASCII characters preceded by a byte specifing its length. The second ;
; format is used to pass file names to DOS and consists of a string of any ;
; ASCII characters terminated by a byte 00. ;
;============================================================================;
;===============================================;
; String_Offset ;
; ;
; Returns the offset of a string whose length ;
; is the first byte. If a literal string is ;
; passed, it is declared with its length as its ;
; first byte. ;
; ;
; STRING - string or location of string: ;
; literal string or 16 bit register, ;
; immediate data, or memory. ;
; LOCATION - storage for string offset: 16 bit ;
; register. ;
;===============================================;
String_Offset Macro String, Location
If Type(String) And Type('')
Jmps B ;jump over declaration
A Db Byte (Offset B - Offset A - 1), String ;declare
B Mov Location, Offset A ;set offset of string
Else
Mov Location, String ;just pass location
Endif
Endm
;===============================================;
; String_Offsetz ;
; ;
; Returns the offset of a string terminated by ;
; a zero. If a literal string is passed, it is ;
; declared with a terminating zero ;
; ;
; STRING - string or location of string: ;
; literal string or 16 bit register, ;
; immediate data, or memory. ;
; LOCATION - storage for string offset: 16 bit ;
; register. ;
;===============================================;
String_Offsetz Macro String, Location
If Type(String) And Type('')
Jmps B ;jump over declaration
A Db String, 0 ;declare
B Mov Location, Offset A ;set offset of string
Else
Mov Location, String ;just pass location
Endif
Endm
;===============================================;
; Declare_String ;
; ;
; Declare a string with the first byte being ;
; its length. ;
; ;
; STRING - string to decalare: literal string. ;
;===============================================;
Declare_String Macro Str1, Str2, Str3, Str4, Str5
A Db Byte (Offset B - Offset A - 1)
If_Exist Str1
Db Str1
Endif
If_Exist Str2
Db Str2
Endif
If_Exist Str3
Db Str3
Endif
If_Exist Str4
Db Str4
Endif
If_Exist Str5
Db Str5
Endif
B
Endm
;===============================================;
; Declare_Stringz ;
; ;
; Declare a string terminated by a byte 00. ;
; ;
; STRING - string to decalare: literal string. ;
;===============================================;
Declare_Stringz Macro Str1, Str2, Str3, Str4, Str5
If_Exist Str1
Db Str1
Endif
If_Exist Str2
Db Str2
Endif
If_Exist Str3
Db Str3
Endif
If_Exist Str4
Db Str4
Endif
If_Exist Str5
Db Str5
Endif
Db 0
Endm
;===============================================;
; Interrupt ;
; ;
; Execute an interrupt, function, and a ;
; subfunction. ;
; ;
; INT_NUM - interrupt: 8 bit immediate data. ;
; FUNC_NUM1 - optional main function (AH): 8 ;
; bit register or immediate data. ;
; FUNC_NUM2 - optional secondary fuction (AL): ;
; 8 bit register or immediate data. ;
;===============================================;
Interrupt Macro Int_Num, Func_Num1, Func_Num2
Push Ax ;parameters on stack
Mov Bp, Sp
If_Exist Func_Num1
Mov Byte [Bp+1], Func_Num1 ;set function (AH)
Endif
If_Exist Func_Num2
Mov Byte [Bp], Func_Num2 ;set subfunction (AL)
Endif
Pop Ax ;restore parameters
Int Int_Num ;execute interrupt
Endm
;===============================================;
; Conditional Statements ;
; ;
; Conditional "if" statements to test if two ;
; operands are identical (IF_SAME) or different ;
; (IF_DIFFERENT) or if an operand exists ;
; (IF_EXIST) or not (IF_NONE). ;
; ;
; OP, OP1, and OP2 - the optional operands to ;
; test: may be any operands. ;
;===============================================;
If_Same Macroc Op1, Op2
If Type(Op1)=Type(Op2) And (Size(Op1)=Size(Op2)) And (Value(Op1)=Value(Op2))
Endm
If_Different Macroc Op1, Op2
Ifn Type(Op1)=Type(Op2) And (Value(Op1)=Value(Op2)) And (Size(Op1)=Size(Op2))
Endm
If_Exist Macroc Op
Ifn Type(Op)=Type()
Endm
If_None Macroc Op
If Type(Op)=Type()
Endm